package com.demo.recycleviewitemdecorationdemo;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;


/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/7/10 11:57
 * 功能：
 */
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.myHolder> {
	private Context context;

	public MyAdapter(Context context) {
		this.context = context;
	}


	@Override
	public myHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(context).inflate(R.layout.item, parent, false);
		return new myHolder(view);
	}

	@Override
	public void onBindViewHolder(myHolder holder, int position) {
		RequestOptions requestOptions = new RequestOptions().transform(new CenterCrop(), new RoundedCorners(15))
				.placeholder(R.color.red);
		Glide.with(context)
				.load("http://img95.699pic.com/photo/50055/5642.jpg_wh300.jpg")
				.apply(requestOptions)
				.into(holder.img);

	}

	@Override
	public int getItemCount() {
		return 30;
	}

	public class myHolder extends RecyclerView.ViewHolder {
		ImageView img;

		public myHolder(View itemView) {
			super(itemView);
			img = itemView.findViewById(R.id.img);
		}
	}
}
